"""
A class to exercise the JT core functions.
"""

import JT
import Calibration
from numpy import array

def Test_ExtCal():
    """
    Test the external calibration
    """
    #fixedFileName = 'C:/Lib/JointTrack/branches/bryan/Images/MovingImage.png'

    fixedFileName = 'C:/Users/bryan/bryan-code/2D3D/vert1/fluoro/ushortim080-LAT.mha'
    volFileName = 'C:/Users/bryan/bryan-code/2D3D/vert1/CT/ucharCTv1r1.mha'
    staFile = 'C:/Users/bryan/bryan-code/2D3D/vert1/CT/ucharCTv1r1.sta'
    calFileLat = 'C:/Users/bryan/bryan-code/trunk/Tests/ext_cal1.txt'
    calFileAP = 'C:/Users/bryan/bryan-code/trunk/Tests/ext_cal2.txt'

    # Generate Lateral Projection
    #----------------------------
    xraycamLat = JT.XRayCamera()
    drrLat = JT.DRR()
    calLat = Calibration.ExternalCalibration()

    calLat.LoadConsolidatedCalibration(calFileLat)
    calLat.LoadStaFile(staFile)
    drrLat.SetXRayCamera(xraycamLat)
    drrLat.SetVolumeFilename(volFileName)

    #Automatic calibration
    xraycamLat.SetExternalCalibration(calLat)


    # The volume position should probably not be a part of the calibration
    vtkMatrixLAT = calLat.ConvertNumpyToVTKArray(calLat._VolumeT)
    drrLat.SetVolumeUserMatrix(vtkMatrixLAT)

    drrLat.SetBlackOnWhiteImage()

    drrLat.SaveGeneratedImage(calFileLat[:-12]+'SaveGeneratedOut.png')

    drrLat.Render()



if __name__ == "__main__":
    Test_ExtCal()